<template>
  <div id="app">
    <img alt="Vue logo" src="./assets/logo.png" />
    <h1>Vuex从应用到原理全解析</h1>
    <h2>{{ $store.state.name }}</h2>
    <h2>技术只要{{ $store.state.age }}岁的</h2>
    <h2>getters:{{ $store.getters.addName }}</h2>
    <button @click="add()">增加10</button>
    <button @click="reduce()">减5</button>
  </div>
</template>
<script>
export default {
  data() {
    return {};
  },
  mounted() {
    console.log(this.$store);
    // setInterval(()=>{
    //   this.$store.state.age+=1
    // },1000)
  },
  methods: {
    add() {
      this.$store.commit("syncAdd", 10);
    },
    reduce() {
      this.$store.dispatch('asyncReduce', 5);
    },
  },
};
</script>
<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}
</style>

